﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using BadmintonApp.Entity;
using BadmintonApp.Factory;
using BadmintonApp.BLL.Interface;
using BadmintonApp.DAO.Interface;

namespace BadmintonApp.BLL.Implement
{
    public class UsersOfRoleBLL : IUsersOfRoleBLL
    {
        private IUsersOfRoleDAO dao;

        /// <summary>
        /// 默认的构造函数
        /// </summary>
        public UsersOfRoleBLL()
        {
            dao = DaoFactory.CreateUsersOfRoleDAO();
        }

        #region IUsersOfRoleBLL Members

        /// <summary>
        /// 插入用户与角色的对应关系
        /// </summary>
        /// <param name="usersOfRoleInfo">用户与角色的对应关系信息类</param>
        public void InsertUsersOfRole(TUsersOfRoleInfo usersOfRoleInfo)
        {
            dao.InsertUsersOfRole(usersOfRoleInfo);
        }

        /// <summary>
        /// 更新用户与角色的对应关系
        /// </summary>
        /// <param name="usersOfRoleInfo">用户与角色的对应关系信息类</param>
        public void UpdateUsersOfRole(TUsersOfRoleInfo usersOfRoleInfo)
        {
            dao.UpdateUsersOfRole(usersOfRoleInfo);
        }

        /// <summary>
        /// 删除用户与角色的对应关系
        /// </summary>
        /// <param name="id">关系ID</param>
        public void DeleteUsersOfRole(int id)
        {
            dao.DeleteUsersOfRole(id);
        }

        /// <summary>
        /// 通过用户ID获取用户与角色的对应关系
        /// </summary>
        /// <param name="userID">用户ID</param>
        /// <returns>对应关系数据集</returns>
        public DataSet GetUsersOfRoleByUserID(int userID)
        {
            return dao.GetUsersOfRoleByUserID(userID);
        }

        /// <summary>
        /// 通过角色ID获取用户与角色的对应关系
        /// </summary>
        /// <param name="roleID">角色ID</param>
        /// <returns>对应关系数据集</returns>
        public DataSet GetUsersOfRoleByRoleID(int roleID)
        {
            return dao.GetUsersOfRoleByRoleID(roleID);
        }

        /// <summary>
        /// 通过用户ID和角色ID获取用户与角色的对应关系
        /// </summary>
        /// <param name="userID">用户ID</param>
        /// <param name="roleID">角色ID</param>
        /// <returns>用户与角色的对应关系信息类</returns>
        public TUsersOfRoleInfo GetUsersOfRoleByUserIDAndRoleID(int userID, int roleID)
        {
            return dao.GetUsersOfRoleByUserIDAndRoleID(userID, roleID);
        }

        #endregion
    }
}
